1. Field of the Invention
This invention relates to data processing systems. More particularly, this invention relates to the saving of processor state data on a stack memory when an exception occurs.
2. Description of the Prior Art
It is known to provide data processing systems operable at multiple privilege levels, such as a user level and a privileged level (different privilege levels have different access permissions within the system, higher levels of privilege having greater access, such as, for example, to instructions, configuration parameters memory, etc.) Within these systems separate stack pointers directed to respective stack memory areas are provided for use in each level of privilege. Accordingly, when operating at the user level the user level stack pointer operates to indicate the memory address to which data values are to be pushed or from which data values are to be popped when a stack memory access is made. Similarly, when operating at the privileged level, a privileged level stack pointer indicates a separate memory address region used as the privileged level stack.
Known operation of such systems responds to the occurrence of an exception when in the user level, whether that be a hardware generated exception or a software generated exception, to switch the processor from the user level to the privileged level. At the same time a corresponding switch is made in the stack pointer to be used. It will be appreciated that the state of the processor prior to the occurrence of the exception needs to be saved such that when the interrupted processing is resumed after the exception has been dealt with, this state information can be restored and the original processing resumed unaltered. Existing systems meet this requirement by providing hardware mechanisms acting upon occurrence of an exception to store certain user level state data onto the privileged level stack as part of the hardware response to the occurrence of the exception. The code responsible for processing the exception within the privilege level acts as one of its first jobs to save off this stacked state data into a task control block associated with the task which was operating prior to occurrence of the exception. In this way, should a further exception occur whilst the original exception is being dealt with, then the original state data is not lost or confused by being submerged on the privileged level stack. When it is desired to return to the original task, the saved state data can be retrieved from the task control block and placed back at the top of the privilege level stack such that when the return is made, this state data can be restored under hardware control back to the original locations and processing resumed.
Within the field of deeply embedded processors one style of operation is to utilise processors that are predominately interrupt driven. Various events which require processing activity to be performed occur largely asynchronously and can be signalled by the generation of an associated interrupt causing the processor to activate appropriate processing code to deal with that processing requirement. Thus, a given processor can be rendered responsible for managing several different events with those events triggering their associated processing activity using interrupts applied to the processor. In the context of such a system, the time taken to switch between processing tasks can become critical. As an example, some processing tasks may have a much higher objective priority than others. A process for controlling a safety critical system should be able to pre-empt an already running process for a non-safety critical system. In this regard the time taken to switch between different processing tasks (contexts) becomes a significant performance parameter.